/*
 * Event.cpp
 *
 *  Created on: 2013-8-7
 *  Author: xnan
 */

#include <ctime>
#include "Event.h"

NS_XNL_BEGIN

Event::Event( Object * p_target, XNint p_eventType, Object * p_userdata )
: m_target( p_target )
, m_currentTarget( NULL )
, m_eventType( p_eventType )
, m_userdata( p_userdata )
, m_stopImmediatePropagation( false )
, m_stopPropagation( false )
{
    XN_RETAIN( m_target );
    XN_RETAIN( m_currentTarget );
    XN_RETAIN( m_userdata );
}

Event::~Event()
{
    XN_RELEASE_NULL( m_target );
    XN_RELEASE_NULL( m_currentTarget );
    XN_RELEASE_NULL( m_userdata );
}

XNint Event::getEventType() const
{
    return m_eventType;
}

Object * Event::getTarget() const
{
    return m_target;
}

Object * Event::getCurrentTarget() const
{
	return m_currentTarget;
}

XNbool Event::isStopImmediatePropagation() const
{
	return m_stopImmediatePropagation;
}

XNbool Event::isStopPropagation() const
{
	return m_stopPropagation;
}

void Event::setTarget( Object * p_target )
{
	XN_RETAIN_SWAP( m_target, p_target );
}

void Event::setCurrentTarget( Object * p_currentTarget )
{
	XN_RETAIN_SWAP( m_currentTarget, p_currentTarget );
}

void Event::setUserdata( Object * p_userdata )
{
    XN_RETAIN_SWAP( m_userdata, p_userdata );
}

void Event::stopImmediatePropagation()
{
	m_stopPropagation = m_stopImmediatePropagation = true;
}

void Event::stopPropagation()
{
	m_stopPropagation = true;
}

NS_XNL_END
